home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libc6.postinst < prev    next >
Text File  |  2009-10-07  |  10KB  |  309 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. type=$1
  6. preversion=$2
  7.  
  8. package_name()
  9. {
  10.     echo libc6
  11. }
  12.  
  13. # element() is a helper function for file-rc:
  14. element() {
  15.     local element list IFS
  16.  
  17.     element="$1"
  18.  
  19.     [ "$2" = "in" ] && shift
  20.     list="$2"
  21.     [ "$list" = "-" ] && return 1
  22.     [ "$list" = "*" ] && return 0
  23.  
  24.     IFS=","
  25.     set -- $list
  26.     case $element in
  27.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  28.         return 0
  29.     esac
  30.     return 1
  31. }
  32.  
  33. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  34. # running in $runlevel:
  35. filerc() {
  36.     local runlevel basename
  37.     runlevel=$1
  38.     basename=$2
  39.     while read LINE
  40.     do
  41.     case $LINE in
  42.         \#*|"") continue
  43.     esac
  44.  
  45.     set -- $LINE
  46.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  47.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  48.  
  49.     if element "$runlevel" in "$START" || element "S" in "$START"
  50.     then
  51.         echo "/etc/init.d/$basename"
  52.         return 0
  53.     fi
  54.     done < /etc/runlevel.conf
  55.     echo ""
  56. }
  57.  
  58. checkpkgver () {
  59.     local status pkg
  60.     pkg=$1
  61.     status=$(dpkg -s $pkg 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  62.     if [ -n "$status" ] && [ "$status" != "not-installed" ] && [ "$status" != "config-files" ]; then
  63.     echo $(dpkg -s $pkg 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//');
  64.     fi
  65. }
  66.  
  67. if [ "$type" = "configure" ]
  68. then
  69.     # Add support for /etc/ld.so.conf.d
  70.     if [ -e /etc/ld.so.conf ]; then
  71.         [ -z "$(tail -n 1 /etc/ld.so.conf)" ] || echo >> /etc/ld.so.conf
  72.     else
  73.         touch /etc/ld.so.conf
  74.     fi
  75.     if ! grep -q '^include /etc/ld.so.conf.d/.*\.conf$' /etc/ld.so.conf ; then
  76.         echo 'include /etc/ld.so.conf.d/*.conf' >> /etc/ld.so.conf
  77.     fi
  78.  
  79.     # We don't use a registry anymore, remove the old file
  80.     rm -f /etc/ld.so.hwcappkgs
  81.  
  82.     # /etc/ld.so.nohwcap code: NOHWCAP
  83.     # Handle upgrades when libc-opt package has been installed.
  84.     # When a /etc/ld.so.nohwcap file exists, ld.so only use libraries
  85.     # from /lib, and ignore all optimised libraries. This file is
  86.     # inconditionaly created in the preinst script of libc.
  87.  
  88.     # Get the list of optimized packages for a given architecture
  89.     # Before removing a package from this list, make sure it appears
  90.     # in the Conflicts: line of libc.
  91.     case $(dpkg --print-architecture) in
  92.         alpha)
  93.             hwcappkgs="libc6-alphaev67"
  94.             ;;
  95.         i386)
  96.             hwcappkgs="libc6-i686 libc6-xen"
  97.             ;;
  98.         kfreebsd-i386)
  99.             hwcappkgs="libc0.1-i686"
  100.             ;;
  101.         sparc)
  102.             hwcappkgs="libc6-sparcv9 libc6-sparcv9b libc6-sparcv9v libc6-sparcv9v2 libc6-sparc64b libc6-sparc64v libc6-sparc64v2"
  103.             ;;
  104.     esac
  105.  
  106.     # We check the version between the current installed libc and
  107.     # all optimized packages (on architectures where such packages
  108.     # exists).
  109.     all_upgraded=yes
  110.     if [ -n "$hwcappkgs" ]; then
  111.         for pkg in $hwcappkgs ; do
  112.             ver=$(dpkg -l $pkg 2>/dev/null | sed -e '/^i/!d;' -e "s/^i.\s\+$pkg\s\+//;s/\s.*//g")
  113.             if [ -n "$ver" ] && [ "$ver" != "2.10.1-0ubuntu15" ]; then
  114.                 all_upgraded=no
  115.             fi
  116.         done
  117.     fi
  118.  
  119.     # If the versions of all optimized packages are the same as the libc
  120.     # one, we could remove /etc/ld.so.nohwcap. Otherwise, it will be removed
  121.     # when all optimized packages are upgraded or removed.
  122.     if [ "$all_upgraded" = yes ] ; then
  123.         rm -f /etc/ld.so.nohwcap
  124.     fi
  125.  
  126.     # Load debconf module if available
  127.     if [ -f /usr/share/debconf/confmodule ] ; then
  128.     . /usr/share/debconf/confmodule
  129.     fi
  130.  
  131.     if [ -n "$preversion" ]; then
  132.     if [ ! -d /var/mail ] && [ ! -L /var/mail ]; then
  133.         ln -sf spool/mail /var/mail
  134.     fi
  135.     if dpkg --compare-versions "$preversion" lt 2.9-5; then
  136.         check="apache2-common apache apache-ssl apache-perl autofs at"
  137.         check="$check boa cucipop courier-authdaemon cron cups exim"
  138.         check="$check exim4-base dovecot-common cucipop lprng lpr"
  139.         check="$check lpr-ppd mysql-server nis openbsd-inetd"
  140.         check="$check openldapd postfix postfix-tls rsync samba"
  141.         check="$check sasl2-bin slapd smail sendmail snmpd ssh"
  142.         check="$check spamassassin vsftpd wu-ftpd wu-ftpd-academ wwwoffle"
  143.         check="$check webmin dropbear"
  144.         # NSS services check: NSS_CHECK
  145.         echo -n "Checking for services that may need to be restarted..."
  146.         # Only get the ones that are installed, and configured
  147.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  148.         # some init scripts don't match the package names
  149.         check=$(echo $check | \
  150.                 sed -e's/\bapache2-common\b/apache2/g' \
  151.                     -e's/\bat\b/atd/g' \
  152.                     -e's/\bdovecot-common\b/dovecot/g' \
  153.                     -e's/\bexim4-base\b/exim4/g' \
  154.                     -e's/\blpr\b/lpd/g' \
  155.                     -e's/\blpr-ppd\b/lpd-ppd/g' \
  156.                     -e's/\bmysql-server\b/mysql/g' \
  157.                     -e's/\bsasl2-bin\b/saslauthd/g' \
  158.         )
  159.         echo
  160.         echo "Checking init scripts..."
  161.         rl=$(runlevel | sed 's/.*\ //')
  162.         for service in $check; do
  163.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  164.                 idl=$(ls /etc/init.d/${service} 2> /dev/null | head -n 1)
  165.                 if [ -n "$idl" ] && [ -x $idl ]; then
  166.                     services="$service $services"
  167.                 else
  168.                     echo "WARNING: init script for $service not found."
  169.                 fi
  170.             else
  171.                 if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  172.                     idl=$(filerc $rl $service)
  173.                 else
  174.                     idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  175.                 fi
  176.                 if [ -n "$idl" ] && [ -x $idl ]; then
  177.                     services="$service $services"
  178.                 fi
  179.             fi
  180.         done
  181.         if [ -n "$services" ]; then
  182.  
  183.             if [ -f /usr/share/debconf/confmodule ] ; then
  184.             db_version 2.0
  185.             db_reset glibc/restart-services
  186.             db_set glibc/restart-services "$services"
  187.             if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  188.             db_input medium glibc/restart-services || true
  189.             else
  190.             db_input critical glibc/restart-services || true
  191.             fi
  192.             db_go || true
  193.             db_get glibc/restart-services
  194.             if [ "x$RET" != "x" ]
  195.             then
  196.                 services="$RET"
  197.             else
  198.                 services=""
  199.             fi
  200.         else
  201.             echo
  202.             echo "Name Service Switch update in the C Library: post-installation question."
  203.             echo
  204.             echo "Running services and programs that are using NSS need to be restarted,"
  205.             echo "otherwise they might not be able to do lookup or authentication any more"
  206.             echo "(for services such as ssh, this can affect your ability to login)."
  207.             echo "Note: restarting sshd/telnetd should not affect any existing connections."
  208.             echo
  209.             echo "The services detected are: "
  210.             echo "        $services"
  211.             echo
  212.             echo "If other services have begun to fail mysteriously after this upgrade, it is"
  213.             echo "probably necessary to restart them too.  We recommend that you reboot your"
  214.             echo "machine after the upgrade to avoid NSS-related troubles."
  215.             echo
  216.             frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  217.             if [ "$frontend" = noninteractive ]; then
  218.                 echo "Non-interactive mode, restarting services"
  219.                 answer=yes
  220.             else
  221.                 echo -n "Do you wish to restart services? [Y/n] "
  222.                 read answer
  223.                 case $answer in
  224.                 N*|n*) services="" ;;
  225.                 *) ;;
  226.                 esac
  227.             fi
  228.         fi
  229.         echo
  230.         if [ "$services" != "" ]; then
  231.             echo "Restarting services possibly affected by the upgrade:"
  232.             failed=""
  233.             for service in $services; do
  234.                 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  235.                 idl="invoke-rc.d ${service}"
  236.             elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  237.                 idl=$(filerc $rl $service)
  238.             else
  239.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  240.             fi
  241.             echo -n "  $service: stopping..."
  242.             $idl stop > /dev/null 2>&1 || true
  243.             sleep 2
  244.             echo -n "starting..."
  245.             if $idl start > /dev/null 2>&1; then
  246.                 echo "done."
  247.             else
  248.                 echo "FAILED! ($?)"
  249.                 failed="$service $failed"
  250.             fi
  251.             done
  252.             echo
  253.             if [ -n "$failed" ]; then
  254.                 if [ -f /usr/share/debconf/confmodule ] ; then
  255.                     db_fset glibc/restart-failed seen false
  256.                 db_subst glibc/restart-failed services "$failed"
  257.                 if [ "$RELEASE_UPGRADE_MODE" = desktop ]; then
  258.                 db_input medium glibc/restart-failed || true
  259.                 else
  260.                 db_input critical glibc/restart-failed || true
  261.                 fi
  262.                 db_go || true
  263.             else
  264.                 echo "The following services failed to start: $failed"
  265.                 echo
  266.                 echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
  267.                 echo "If the service still fails to start, you may need to file a bug on"
  268.                 echo "$(package_name) or the service involved."
  269.                 frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  270.                 if [ "$frontend" != noninteractive ]; then
  271.                     echo
  272.                     echo -n "Press ENTER to continue: "
  273.                     read foo
  274.                 fi
  275.             fi
  276.             else
  277.             echo "Services restarted successfully."
  278.                     fi
  279.         fi
  280.                 # Shut down the frontend, to make sure none of the
  281.         # restarted services keep a connection open to it
  282.             if [ -f /usr/share/debconf/confmodule ] ; then
  283.             db_stop
  284.         fi
  285.         else
  286.         echo "Nothing to restart."
  287.         fi
  288.     fi # end upgrading and $preversion lt 2.6-1
  289.     fi # Upgrading
  290.  
  291.     # Generate cache file /usr/lib/gconv/gconv-modules.cache
  292.     iconvconfig || true
  293.  
  294.     if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
  295.       # the devicenumber/inode pair of / is the same as that of /sbin/init's
  296.       # root, so we're *not* in a chroot
  297.       (telinit u ; sleep 1)
  298.     fi
  299. fi
  300.  
  301. # Automatically added by dh_makeshlibs
  302. if [ "$1" = "configure" ]; then
  303.     ldconfig
  304. fi
  305. # End automatically added section
  306.  
  307.  
  308. exit 0
  309.